<template>
    <div>
        <router-link to="/login">登录</router-link> &nbsp;
        <el-button type="primary" @click="openInfoWidnow">打开信息弹窗</el-button> &nbsp;
        <el-button type="primary" @click="openAdvanceSearch">打开高级搜索弹窗</el-button> &nbsp;
        <el-button type="primary" @click="openWindow">打开客户端弹窗</el-button> &nbsp;
        <el-button type="primary" @click="openWindowCallback">打开客户端弹窗并回调</el-button> &nbsp;
        <el-button type="primary" @click="openSelect">打开选择数据弹窗</el-button> &nbsp;
        <el-button type="primary" @click="openViewDetail">打开查看详情弹窗</el-button> &nbsp;
        <el-button type="primary" @click="getLocal">测试缓存</el-button> &nbsp;
        <el-button type="primary" @click="init">重置</el-button> &nbsp;
        <el-button type="primary" @click="onLoading">显示loading</el-button>
        <el-button type="primary" @click="onClick1">打开网页端弹窗</el-button>
    </div>
</template>

<script>
import { mapMutations, mapState } from 'vuex'
// eslint-disable-next-line no-unused-vars
import { showLoading, openAppClient, advanceSearch, selectDataClient, openAppClientViewDetail } from '@/utils/common'
export default {
    computed: {
        ...mapState(['userInfo']),
        ...mapState('equip', ['equipData'])
    },
    data () {
        return {}
    },
    mounted () {
        console.log('userInfo: ', this.userInfo)
        window.test = params => {
            alert(params)
        }
    },
    methods: {
        ...mapMutations(['setSelectedInfo']),
        init () {
            localStorage.clear()
        },
        reOpen () {
            this.$router.push(`/?a=${Math.random()}`)
        },
        getLocal () {
            const test = localStorage.getItem('test')
            alert(test)
            localStorage.setItem('test', '缓存有值了')
            this.setSelectedInfo(this.equipData)
            openAppClient('/showSelectedData', '设备状态值')
        },
        openInfoWidnow () {
            this.clientPop('suc', '成功提示信息', result => {
                alert('确定: ' + JSON.stringify(result))
            }, {
                aaa: 111
            }, result => {
                alert('取消: ' + JSON.stringify(result))
            })
        },
        openAdvanceSearch () {
            advanceSearch('/guochengJieshuanSearch')
                .then(res => {
                    // console.log(res.toString())
                    alert('搜索条件：' + JSON.stringify(res))
                    // selectDataClient({
                    //     SelectServiceToken: '/hr/org/getChildrenOrg', // 客户端对应方法名
                    //     IsSingleMode: true, // 是否单选 true 单选 false 多选
                    //     SelectedIDs: [], // 已选中id(注意：是上一次已选中的id，不是要传的参数，如果第一次选，则传[])
                    //     InitParamsStr: '',    // 接口参数(name为模拟参数)
                    //     Title: '选择机构' // 标题
                    // }).then(val => {
                    //     console.log(val.toString())
                    //     this.setSelectedInfo(val)
                    //     this.openWindow()
                    // })
                })
                .catch(err => {
                    alert(err.toString())
                })
        },
        openWindow () {
            openAppClient('/showSelectedData', '选择结果', res => {
                alert('弹窗关闭时回调:' + res.toString())
            })
        },
        openWindowCallback () {
            openAppClient('/showSelectedData', '', null, null, null, 'testFun')
        },
        openSelect () {
            // this.setSelectedInfo(123)
            // this.openWindow()
            selectDataClient({
                SelectServiceToken: '/turnover/receive/returnSelectContract', // 客户端对应方法名
                IsSingleMode: false, // 是否单选 true 单选 false 多选
                SelectedIDs: [], // 已选中id
                InitParamsStr: '-1',    // 接口参数
                Title: '选择分包商' // 标题
            }).then(val => {
                this.setSelectedInfo(val)
                this.openWindow()
            }).catch(err => {
                alert(err)
            })
        },
        openViewDetail () {
            openAppClientViewDetail('Com.Scrbg.Pcwp2.EngineeringView.EngineeringSummaryInfo.EditEngineeringSummaryInfoView', '查看工程概况', '1514064298087477250')
        },
        onLoading () {
            showLoading('loading')
        },
        onClick1 () {
            openAppClient('/switchorg', '选择机构', res=>{console.log(res)}, null, ()=>{console.log(2)})
        },
    }
}
</script>
<style lang="scss">
.index {
    .a {
        display: inline;
    }
}
</style>
